package com.qfhd.soft.cjzcore.Model;

import com.qfhd.soft.cjzcore.Core.CJJsonUtils;

import org.json.JSONObject;

public class Task_try_model {
    public String tid; //标识
    //'apk_icon', 'apk_name', 'apk_url', 'tid', 'expire_time', 'full_reward',remain
//    @SerializedName("apk_icon")
    public String icon;

//    @SerializedName("apk_name")
    public String title;

//    @SerializedName("full_reward")
    public int coin;

    public int remain;//库存量

//    @SerializedName("apply_at")
    public long timeStamp;//抢完任务后的开始时间

//    @SerializedName("expire_time")
    public int validTime;//任务有效时长

//    @SerializedName("ut_state")
    public boolean isGetTask;

    public boolean isGetTask(){
        return isGetTask;
    }

    public static Task_try_model create(String iconurl,String title,int coin,int remain,boolean isGetTask){
        Task_try_model model = new Task_try_model();
        model.icon = iconurl;
        model.title = title;
        model.coin = coin;
        model.remain = remain;
        model.isGetTask = isGetTask;
        return model;
    }

    public static Task_try_model getModelByJSONObject(JSONObject object){
        Task_try_model try_model = new Task_try_model();
        try_model.icon = CJJsonUtils.getValueFromKey_string(object,"apk_icon");
        try_model.coin = CJJsonUtils.getValueFromKey_int(object,"full_reward");
        try_model.isGetTask = CJJsonUtils.getValueFromKey_boolean(object,"ut_state");
        try_model.remain = CJJsonUtils.getValueFromKey_int(object,"remain");
        try_model.tid = CJJsonUtils.getValueFromKey_string(object,"tid");
        try_model.timeStamp = CJJsonUtils.getValueFromKey_long(object,"apply_at");
        try_model.title = CJJsonUtils.getValueFromKey_string(object,"apk_name");
        try_model.validTime = CJJsonUtils.getValueFromKey_int(object,"expire_time");
        return try_model;
    }
}
